package cc.wsyw126.java.Regex;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by junpeng.yang on 16/11/15.
 */
public class RG {
    public static void main(String[] args) {
        Pattern pattern = Pattern.compile("((\\d{11})|([0][1-9]{2,3}-(\\d{7,8})))");

        String text = "0371-12345678/;;;;;12345678|13522158842;托尔斯泰;test2;13000002222;8613111113313,0371-912345678///12345678911||1234532323343322344";
        Matcher matcher = pattern.matcher(text);
        List<String> mobile = new ArrayList<>();
        while (matcher.find()) {
            mobile.add(matcher.group());
        }

        for (String s : mobile) {
            System.out.println("s = " + s);
        }

        String s = mobile.get(0);
        if (s.contains("-")) {
            s = s.replace("-", "");
        }

        System.out.println("s = " + s);
    }
}
